﻿using System;
using System.Web.UI;
using newtelligence.DasBlog.Runtime;
using newtelligence.DasBlog.Web.Core;

namespace HarrisDesigns.Controls.dasBlogControls
{
    public class Macros
    {
        protected Entry currentEntry;
        protected SharedBasePage sharedBasePage;

        public Macros(SharedBasePage page, Entry entry)
        {
            sharedBasePage = page;
            currentEntry = entry;
        }

        public virtual Control TwitterStatus(string user)
        {
            return TwitterStatus(user, 10);
        }

        public virtual Control TwitterStatus(string user, int tweetCount)
        {
            return TwitterStatus(user, tweetCount, 5);
        }

        public virtual Control TwitterStatus(string user, int tweetCount, int pollingMinutes)
        {
            if (String.IsNullOrEmpty(user) || tweetCount < 1 || tweetCount > 20 || pollingMinutes < 1)
                return new LiteralControl("");

            return new TwitterStatusControl { TwitterAccount = user, TweetCount = tweetCount, PollingMinutes = pollingMinutes };
        }

        public virtual Control GoogleReaderSharedItems(string user)
        {
            return GoogleReaderSharedItems(user, 10);
        }

        public virtual Control GoogleReaderSharedItems(string user, int itemCount)
        {
            return GoogleReaderSharedItems(user, itemCount, 5);
        }

        public virtual Control GoogleReaderSharedItems(string user, int itemCount, int pollingMinutes)
        {
            if (String.IsNullOrEmpty(user) || itemCount < 1 || itemCount > 20 || pollingMinutes < 1)
                return new LiteralControl("");

            return new GoogleReaderSharedItemsControl() { GoogleAccountIdentity = user, ItemCount = itemCount, PollingMinutes = pollingMinutes };
        }
    }
}